package com.learn.jdk8.lambda04;

import java.util.Date;
import java.util.HashMap;

public class Test {

    private static void newThread(Runnable runnable){
        new Thread(runnable).start();
    }

    public static void main(String[] args) {
        Date date = new Date();
        HashMap<Object, Object> map = new HashMap<>();
        map.put(1, 6);
        newThread(new Runnable() {
            @Override
            public void run() {
                date.setTime(1000000);
                map.put(2, 6);
                System.out.println("匿名内部类当前线程-"+Thread.currentThread().getName());
            }
        });

        //todo lambda
        newThread(()->{
            int i=0;
            i++;
            map.put(1, 8);
            map.put(3, new Date());
            System.out.println("lambda表达式线程-"+Thread.currentThread().getName());
        });

        System.out.println(map);
        System.out.println("------------------------>");
        System.out.println(date);

        //todo lambda表达式简化
        newThread(()->
                System.out.println("lambda表达式简化线程-"+Thread.currentThread().getName())
        );



    }
}
